@extends('admin.layouts.head')
@section('content')
    <body>
    <div id="app">
        <div class="wrapper -header-fixed">

        @include('admin.layouts.navbar')
        @include('admin.layouts.sidebar')

        <!-- 内容页开始-->
            <div class="content-container">
                <div class="container-fluid">
                    <div class="page-content">

                        <nav aria-label="breadcrumb">
                            <ol class="breadcrumb">
                                <li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">仪表盘</a></li>
                                <li class="breadcrumb-item"><a href="{{ route('admin.rechargeRule.index') }}">规则列表</a></li>
                                <li class="breadcrumb-item active" aria-current="page">新增编辑</li>
                            </ol>
                        </nav>

                        <div class="card">
                            <div class="card-body">

                                <div class="row">
                                    <div class="col-lg-5">
                                        <div class="col-lg-12">
                                            <div class="form-group">
                                                <label>充值金额：</label>
                                                <input type="text" class="form-control" id="need_money" value="{{ $detail->need_money ?? 0 }}">
                                            </div>
                                        </div>
                                        <div class="col-lg-12">
                                            <div class="form-group">
                                                <label>赠送乐游币：</label>
                                                <input type="text" class="form-control" id="gift_ly" value="{{ $detail->gift_ly ?? 0 }}">
                                            </div>
                                        </div>
                                        <div class="col-lg-12">
                                            <div class="form-group">
                                                <label>赠送玩服积分：</label>
                                                <input type="text" class="form-control" id="gift_wf" value="{{ $detail->gift_wf ?? 0 }}">
                                            </div>
                                        </div>
                                        <div class="col-lg-12">
                                            <div class="form-group">
                                                <label>赠送新红包币：</label>
                                                <input type="text" class="form-control" id="gift_hb" value="{{ $detail->gift_hb ?? 0 }}">
                                            </div>
                                        </div>

                                        <div class="col-lg-12">
                                            <div class="form-group">
                                                <button class="btn btn-primary" onclick="operation_tip2({{$detail->id ?? 0}})">提交</button>
                                            </div>
                                        </div>
                                    </div>

                                </div> <!-- .row -->
                            </div> <!-- .card-body -->
                        </div> <!-- .card -->

                    </div> <!-- .page-content -->
                </div> <!-- .container-fluid -->
            </div> <!-- .content-container -->
        </div> <!-- .wrapper -->
    </div> <!-- #app -->
    <script src="{{ mix('js/app.js') }}"></script>
    <script src="{{ asset('/js/main.js') }}"></script>
    <script>

        let isLoading = false;

        //提交
        function submit(id) {

            if (isLoading === false) {
                isLoading = true;

                axios.patch('{{ route('admin.rechargeRule.update','').'/' }}' + id + '', {
                    need_money: $('#need_money').val(),
                    gift_ly: $('#gift_ly').val(),
                    gift_wf: $('#gift_wf').val(),
                    gift_hb: $('#gift_hb').val(),
                })
                    .then(function (response) {
                        isLoading = false;
                        toast(response.data.message);
                        if (response.data.success === 'true') {
                            setTimeout(() => {
                                window.location.href='{{ route('admin.rechargeRule.index') }}';
                            }, 2000)
                        }
                    })
                    .catch(function (error) {
                        isLoading = false;
                        $.each(error.response.data.errors, function (index, object) {
                            toast(object[0]);
                            return false;
                        });
                    })
            }
        }
    </script>
    </body>

@endsection
